<script setup>
  import { ref } from 'vue'
  import { onLoad, onShow, onBackPress } from '@dcloudio/uni-app'
  const id = ref(0)
  const from = ref('mall')
  function checkOrder() {
    // uni.switchTab({
    // 	url: '/pages/mine/index',
    // })
    // 查看订单详情
    uni.navigateTo({
      url: `/minePage/orderdetail/index?id=${id.value}&from=${from.value}`,
    })
  }
  function backTo() {
    uni.reLaunch({
      url: `/pages/home/index`,
    })
  }
  onBackPress((option) => {
    console.log(option)
    if (options.from === 'navigateBack') {
      uni.utils.toast('当前页禁止返回上一页')
      return true
    }
  })
  onLoad((option) => {
    id.value = option.id
    from.value = option.from
  })
</script>

<template>
  <view class="success-content">
    <image
      style="width: 220rpx; height: 220rpx"
      src="../../static/success.png"
      mode=""
    ></image>
    <view class="success-text"> 支付成功 </view>
    <view class="notice">
      可以在我的"{{ from == 'mall' ? '商城订单' : '发货订单' }}"查看
    </view>
    <view class="check-button" @click="checkOrder"> 查看订单 </view>
    <view class="go-back" @click="backTo"> 返回首页 </view>
  </view>
</template>

<style lang="scss" scoped>
  .success-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100vh;
    padding-top: 270rpx;
    box-sizing: border-box;
    .success-text {
      margin: 24rpx 0 12rpx 0;
      font-weight: 700;
      font-size: 40rpx;
      color: #3d3d3d;
    }
    .notice {
      margin-bottom: 38rpx;
      font-weight: 700;
      font-size: 28rpx;
      color: #9b9b9d;
    }
    .check-button {
      width: 380rpx;
      height: 86rpx;
      margin-bottom: 38rpx;
      border-radius: 43rpx;
      box-sizing: border-box;
      background-color: $all-color;
      line-height: 86rpx;
      text-align: center;
      font-size: 32rpx;
      color: #3d3d3d;
      font-weight: 600;
    }
    .go-back {
      width: 380rpx;
      height: 86rpx;
      border-radius: 43rpx;
      border: 4rpx solid #9b9b9d;
      box-sizing: border-box;
      line-height: 78rpx;
      text-align: center;
      font-size: 32rpx;
      color: #9b9b9d;
    }
  }
</style>
